package stu.day1_day8;

public class LeetCode1184 {
    public int distanceBetweenBusStops(int[] distance, int start, int destination) {
        int allNum = 0;
        int num = 0;
        for (int i = 0; i < distance.length; i++) {
            allNum += distance[i];
        }
        int x =start<destination?start:destination;
        int y =start<destination?destination:start;
        for (int i = x; i < y; i++) {
            num += distance[i];

        }
        return num<allNum-num?num:allNum-num;

    }

    public static void main(String[] args) {

    }
}
